package no.hig.imt4721.matching;

import no.hig.imt4721.model.Repetition;
import no.hig.imt4721.model.Template;

public class DistanceMetricEuclidean extends DistanceMetric
{
	public double getDistance(Template template, Repetition repetition)
	{	
		double d = 0;
		
		for(int i = 0; i < repetition.getLengthOfRow(); i++)
		{
			d += getSingleFeatureDistance(template.getValue(i), repetition.getRowElement(i));
		}
		
		return Math.sqrt(d);
	}
	
	private double getSingleFeatureDistance(double inputValue, double templateValue)
	{
		return Math.pow(inputValue - templateValue, 2);
	}
}